﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using Solution.Business.Component;
using Solution.Business.Entities;
using Solution.Data;

namespace Solution.UI.Web.Controllers.Admin
{
    public class AdminContactController : Controller
    {
        private SolutionEntities db = new SolutionEntities();
        //
        // GET: /AdminContact/

        public ActionResult Index()
        {
            var list = db.Contacts.OrderBy(c => c.CId);
            return View(list.ToList());
        }

        public ActionResult Details(int id = 0)
        {
            Contact contact = db.Contacts.Find(id);
            if (contact == null)
            {
                return HttpNotFound();
            }
            return View(contact);
        }

        public ActionResult Delete(int id = 0)
        {
            Contact contact = db.Contacts.Find(id);
            if (contact == null)
            {
                return HttpNotFound();
            }
            return View(contact);
        }

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var contact = db.Contacts.Find(id);
            db.Contacts.Remove(contact);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
